...Welcome to Quake3World...


Note: This is an archived, read-only topic.
  Quake3World.com Forums
  Quake III Arena Editing Archive
  Q3 Documentation Project (Page 2)

logon | profile | register | preferences | faq | search | game servers


This topic is 2 pages long:   1  2 
Originally posted in Programming Discussion

Email This Thread to a Friend!

Author Topic:   Q3 Documentation Project
Timbo
Linux+Quake=Good

Posts: 923
Registered: Jun 2000

posted 08-22-2001 06:34 PM     Click Here to See the Profile for Timbo Visit Timbo's Homepage!   Click Here to Email Timbo UIN: 38321905UIN: 38321905 
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize )

const char *path: String reflecting a directory.
const char *extension: File extension to list (incluing a leading period).
char *listbuf: Pointer to a buffer to fill.
int bufsize: Length of the buffer.

This fills listbuf with a NULL delimited list of all the files in the directory specified by path ending in extension. The number of files listed is returned.

Timbo
Linux+Quake=Good

Posts: 923
Registered: Jun 2000

posted 08-22-2001 06:36 PM     Click Here to See the Profile for Timbo Visit Timbo's Homepage!   Click Here to Email Timbo UIN: 38321905UIN: 38321905 
int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points)

int color:
int numPoints:
vec3_t *points:

?

D!ABLO:
creates a solid coloured permanent polygon in the renderer (and world) based on the given array of vertices/points.
it returns a reference handle to the polygon as it appears in the renderlist.
this function should be disabled, but it may still work.

[This message has been edited by D!ABLO : 08-23-2001.]

Timbo
Linux+Quake=Good

Posts: 923
Registered: Jun 2000

posted 08-22-2001 06:36 PM     Click Here to See the Profile for Timbo Visit Timbo's Homepage!   Click Here to Email Timbo UIN: 38321905UIN: 38321905 
void trap_DebugPolygonDelete(int id)

int id: a value previously returned by trap_DebugPolygonCreate

D!ABLO:
removes a polygon that was previously created via trap_DebugPolygonCreate.

[This message has been edited by D!ABLO : 08-23-2001.]

Timbo
Linux+Quake=Good

Posts: 923
Registered: Jun 2000

posted 08-22-2001 06:42 PM     Click Here to See the Profile for Timbo Visit Timbo's Homepage!   Click Here to Email Timbo UIN: 38321905UIN: 38321905 
void trap_SnapVector( float *v )

float *v:Vector to snap.

This simply removes the fractional part of each axis of v - a form of "snap to grid". Its purpose is to save network bandwidth by exploiting the fact that delta compression will only transmit the changes in state of a struct. A changing vector will change less frequently if only the integral part is taken into account.

RR2DO2
Insane Quaker

Posts: 406
Registered: Jun 2000

posted 08-22-2001 08:05 PM     Click Here to See the Profile for RR2DO2 Visit RR2DO2's Homepage!   Click Here to Email RR2DO2 
int trap_RealTime( qtime_t *qtime )

qtime_t *qtime: Point in time - look at q_shared.h qtime_t for details.

Returns current system time and date at server.

[This message has been edited by RR2DO2 : 08-22-2001.]

D!ABLO
Immortal

Posts: 2125
Registered: Dec 1999

posted 09-01-2001 06:54 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);

arg0 - the name of the .RoQ file to load.

xpos - the X coordinate on-screen for the left edge of the cinematic display.

ypos - the Y coordinate on-screen for the top edge of the cinematic display.

width - the screen width of the cinematic display.

height - the screen height of the cinematic display.

bits - combinations of the following flags:

  • CIN_system
  • CIN_loop
  • CIN_hold
  • CIN_silent
  • CIN_shader
    OR them together to use multiple. eg. CIN_loop|CIN_silent

    this function loads up and begins playing an ROQ file at the coordinates given. if the CIN_hold flag is specified, the ROQ is loaded in a paused state. the function returns a handle to the cinematic instance or zero on failure.

    [This message has been edited by D!ABLO : 09-01-2001.]

  • D!ABLO
    Immortal

    Posts: 2125
    Registered: Dec 1999

    posted 09-01-2001 07:14 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
    e_status trap_CIN_StopCinematic(int handle);

    handle - the handle returned by a previous call to trap_CIN_PlayCinematic

    from the code:
    stops playing the cinematic and ends it. should always return FMV_EOF
    cinematics must be stopped in reverse order of when they are started


    D!ABLO
    Immortal

    Posts: 2125
    Registered: Dec 1999

    posted 09-01-2001 07:16 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
    e_status trap_CIN_RunCinematic(int handle);

    handle a handle returned by a previous call to trap_CIN_PlayCinematic

    from the code:
    will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.


    D!ABLO
    Immortal

    Posts: 2125
    Registered: Dec 1999

    posted 09-01-2001 07:18 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
    void trap_CIN_DrawCinematic (int handle);

    handle - a handle returned by a previous call to trap_CIN_PlayCinematic

    this function renders the current frame of the cinematic to the screen with the current position coordinates.


    D!ABLO
    Immortal

    Posts: 2125
    Registered: Dec 1999

    posted 09-01-2001 07:20 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
    void trap_CIN_SetExtents (int handle, int x, int y, int w, int h);

    handle - a handle returned by a previous call to trap_CIN_PlayCinematic

    x - the new X coordinate on-screen of the left edge of the cinematic.

    y - the new Y coordinate on-screen of the top edge of the cinematic.

    w - the new width on-screen of the cinematic.

    h - the new height on-screen of the cinematic.

    from the code:
    allows you to resize the animation dynamically


    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 09-15-2001 05:43 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_Cvar_VariableStringBuffer(const char *var_name, char *buffer, int bufsize)

    var_name: name of cvar (console variable).
    buffer: destination string buffer.
    bufsize: maximum limit of string buffer.

    This trap copies the content of a cvar named by var_name into a mod-space string. This is useful for obtaining cvar contents that are not bound, or cannot be bound, to a vmCvar_t variable in the mod code.

    The terminating NULL is attached to the end of the copied string by this trap, guaranteeing buffer holds a null-terminated string. The total number of characters copied, including terminating NULL, fits within the size specified by bufsize, truncating the string if necessary.

    A nonexistent cvar provides an empty string. An existing cvar with empty content also provides an empty string. Thus, this trap is not sufficient to determine if a cvar actually exists or not.

    This trap does not create a new cvar; to create a new cvar during run-time, you can use trap_Cvar_Set or trap_SendConsoleCommand.

    [This message has been edited by PhaethonH : 09-15-2001.]

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 04:11 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_SendConsoleCommand( int exec_when, const char *text )

    exec_when: When to execute command: EXEC_NOW, EXEC_INSERT, EXEC_APPEND
    text: Console command to run.

    The string provided by text is run as if typed as a command into the console. A leading slash (/) is not required.

    Description of the EXEC_* values are described in q_shared.h.

    In general, EXEC_APPEND is the most common use, simulating the user typing in the command. The string is stored to a buffer (appended) until a game frame is completed, then the engine will examine the buffered strings to run.

    EXEC_NOW is a bad idea, as it can lead to an infinite loop: EXEC_NOW causes an immediate jump into engine space, which then jumps back to QVM/mod space to execute commands, which could lead to an immediate jump right back to engine space, which would lead to... and so on.

    Useless examples:

    trap_SendConsoleCommand(EXEC_APPEND, "team free");
    trap_SendConsoleCommand(EXEC_APPEND, "say Vini vidi vici.; quit");

    [PS]OK, so Timbo already did this, but I was looking at the CGAME's list, which didn't have this one crossed out. [/PS]

    [This message has been edited by PhaethonH : 02-16-2002.]

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 04:26 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_AddCommand( const char *cmdName )

    cmdName: Command name.

    The string cmdName is added to a tab-completion list for the console. Tab completion is case-insensitive, but the completed string is rewritten with the stored capitalization.

    Commands added to the commands[] array are automatically addded for tab-completion by the function CG_InitConsoleCommands(), and, in fact, this is the only function that calls this trap in the baseq3 game source.

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 05:21 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_SendClientCommand( const char *s )

    s: Command string

    Sends command string as a client command directly to server. In contrast, trap_SendConsoleCommand() sends the string to the local console first, and, if not recognized there, sends to the server as a client command.

    This trap makes no distinction among EXEC_NOW, EXEC_INSERT, or EXEC_APPEND as with trap_SendConsoleCommand(), since the command is sent "somewhere else".

    The set of "client commands" is separate from "console commands", so that a misbehaving client cannot kill a server by attempting to send "quit" as a command.

    In baseq3, the common SendClientCommand commands are "score" (to obtain information for scoreboard), "tell" (chat, commands), and "vtell" (Q3TA chat with WAV playback).

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 05:40 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    qboolean trap_Key_IsDown( int keynum )

    keynum: A key keynum

    Returns true is the indicated key is held down, returns false if not held down (released).

    The values of keynum range from 0 to 255, inclusive. For the most part, a key's keynum corresponds to its character's ASCII value (e.g. the 'A' key is 65).

    I have a list of keynames used by the bind command with their keynums which I may append at a later date. In the meantime, if you want to know them now, you can do this:

    Create a keynums.cfg with a pattern like:
    bind 0x00 Key 0x00
    bind 0x01 Key 0x01
    ...
    bind 0xfe Key 0xfe
    bind 0xff Key 0xff

    (case matters for the hex values, and a scripting language to automate this really helps)

    Back up your q3config.cfg, run Q3, "/exec keynums.cfg; bindlist; condump keynums.txt; quit"

    In the file "keynums.txt" you should now have lines like:
    UPARROW "Key 0x84"

    There's your keynum list.


    (Generating keynums.cfg in GNU bash:
    for i in $(seq 0 255); do x=$(printf "%02x" $i); echo bind 0x$x Key 0x$x; done > keynums.cfg
    )


    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 05:55 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_Key_SetCatcher( int catcher )

    catcher: Key catchers bitmask

    Redirects key events to different module(s).

    Normally, key events are interpreted by the engine, affected by the key bindings. This trap allows you redirect key events to other components.

    Valid catchers are:
    KEYCATCH_CONSOLE: the console
    KEYCATCH_UI: the ui module
    KEYCATCH_MESSAGE: the little message editor thingy
    KEYCATCH_CGAME: the cgame module

    These are bitmasked values, meaning you can combine them with the OR operator (|), as in (KEYCATCH_UI|KEYCATCH_CGAME), but I recommend against trying multiple catchers (it may get confusing).

    As a mods programmer, you may be most interested in KEYCATCH_CGAME, and on this I will concentrate this entry.

    --- The Keyboard ---

    When key-catching is enabled (trap_Key_SetCatcher(KEYCATCH_CGAME);), upon a change in key state (gets pressed or gets released), the engine calls the vmMain() function in cg_main.c with the following parameters:
    command = CG_KEY_EVENT
    arg0 = keynum
    arg1 = 1 if pressed, 0 if released.

    In baseq3 game source, this event is already handled and delegated to CG_KeyEvent(), which is empty.

    The values for keynum are the same as for trap_Key_IsDown().

    Key catching is disabled by calling with a parameter of 0 (as in, no catchers). Key catching is also terminated if the user presses the ESC key, which means you won't receive events on the ESC key.

    --- The Mouse ---

    When key-catching is enabled, mouse movement is also redirected to the specified module. When the engine detects mouse movement, it calls vmMain() with the following parameters:
    command = CG_MOUSE_EVENT
    arg0 = relative X position
    arg1 = relative Y position

    The game source for baseq3 delegates this event to CG_MouseEvent().

    Pointer Device Movement - Reported Value:
    Left - Negative X
    Right - Positive X
    Up - Negative Y
    Down - Positive Y

    The engine only reports mouse movement -- if the mouse doesn't move, there is no mouse event. The engine reports mouse buttons and wheels (if any) as key events, for binding purposes.

    Cvars do not influence the reported values.

    [This message has been edited by PhaethonH : 03-22-2002.]

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 06:00 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    int trap_Key_GetCatcher( void )

    (no parameters)

    Returns a bitmask representing active key catchers.

    Bitmask values are:
    KEYCATCH_CONSOLE
    KEYCATCH_UI
    KEYCATCH_MESSAGE
    KEYCATCH_CGAME

    (see also trap_Key_SetCatcher())

    To check if CGAME key-catching is active:
    if (trap_Key_GetCatcher() & KEYCATCH_UI) {
    /* happy happy */
    }


    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-16-2002 06:04 PM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    int trap_Key_GetKey( const char *binding )

    binding: command string presumably bound to a key.

    Returns keynum of the key that has the binding specified by binding. Case-sensitive.

    Unknown: what happens when many keys have this binding.

    PhaethonH
    Veteran

    Posts: 197
    Registered: Sep 2001

    posted 02-17-2002 02:28 AM     Click Here to See the Profile for PhaethonH Visit PhaethonH's Homepage!    UIN: 20360675UIN: 20360675 
    void trap_RemoveCommand( const char *cmdName )

    cmdName: command name

    Although this trap is not actually used anywhere in baseq3 game source, a reasonable assumption, based on function name and parameters, is that this trap removes a command name from the list of command completions. That is, the inverse of trap_AddCommand().

    Unknown: case sensitivity (i.e. if capitalization matters for string matching)

    TimOtholt
    Gibblet

    Posts: 17
    Registered: Feb 2002

    posted 02-27-2002 10:06 AM     Click Here to See the Profile for TimOtholt     
    int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points)

    int color:
    int numPoints:
    vec3_t *points:

    ?

    D!ABLO:
    creates a solid coloured permanent polygon in the renderer (and world) based on the given array of vertices/points.
    it returns a reference handle to the polygon as it appears in the renderlist.
    this function should be disabled, but it may still work.

    TimOtholt:
    In Q3 1.31, only a single debug polygon can be displayed at once. Calling trap_DebugPolygonCreate() to draw a second polygon causes none of them to be drawn on the screen. Delete the old polygon before trying to draw the new one.


    D!ABLO
    Immortal

    Posts: 2125
    Registered: Dec 1999

    posted 06-28-2002 11:20 PM     Click Here to See the Profile for D!ABLO Visit D!ABLO's Homepage!   Click Here to Email D!ABLO UIN: 17861734UIN: 17861734 
    void trap_SetBrushModel( gentity_t *ent, const char *name );

    gentity_t* ent : The entity to apply the collision map to.

    const char* name : The name of the brush model. If the model is inline (built into the map) it will "*0", "*1", "*n". These names are generated by the map compiler and cannot be changed. "*0" is always the map itself. If the model is external to the map then it is the filename of the BSP (another map is technically valid as a stand-alone model though it is not externally lit and all external surfaces are backfaced culled).

    This function does several special things to an entity which should not be done any other way.

  • It sets the clipping bounds of the entity to use the collision map contained in the brush model specified. Brush models have a complex collision map which is far more detailed than a regular bounding-box (doors, plats, movers etc). The mins and maxes of a brush-model entity may differ wildly from reality.
  • It sets the entity to have the SOLID_BMODEL type which serves to alert clients that the modelindex used to render this entity is not in the regular list, but instead is the index into the cgs.inlineDrawModel list which is built on start-up. This list is zero-indexed from *1 and therefore does not contain the map itself. Another method must be used to get the client to render the map a second time.
  • It sets the "bmodel" member of the entityShared_t structure to 1 (entityShared_t is the "r" member of the gentity_t structure). This allows a simple method of checking if an entity uses a brush model.

    There is nothing to prevent an entity from using a brush model which is not built into the map (not inline). However this ability is not used anywhere in Q3A or Q3TA. The map compilers have special command-line switches to build BSPs which are externally lit and designed to be stand-alone models. If this is attempted the cgame QVM will require special code (a bit-flag or similar) to allow it to know the difference between a brush-model index that is inline and one that is external.

    And thats' the last function in the game list!!

    quote:
    Originally posted by ydnar:
    This is news to me. Which switches are you referring to?

    y


    [This message has been edited by Timbo : 11-06-2002.]

  • Nith Sahor
    Recruit

    Posts: 9
    Registered: Sep 2002

    posted 09-28-2002 03:54 AM     Click Here to See the Profile for Nith Sahor     UIN: 118030089UIN: 118030089 
    void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );

    const vec3_t org: origin of the light - where the light will be.

    float intensity: not the exact intensity of the light, but the radius of the light - the light is a sphere-like object and points within that object are lighted up, and the closer something is to the origin of the light (org) the closer the light will be to the actual colour data of the light.

    float r/g/b: this is the colour data of the light (normalized, so the highest value, 255, is 1.0) - r is the amount of red light, g green light, and b blue light.

    This function will add a light to the game at org, which has a radius of intensity units, and the colour data which is shown in the variables r, g, and b. The highest number for an RGB index is 255, but in Quake 3 the colour's index is divided by 255 to give a normalized value.

    Say I want to make a purple light. The colour data for purple in RGB is 255,0,255. So the normalized values for this colour are:

    255/255 = 1.0
    0/255 = 0.0
    255/255 = 1.0

    So to add a purple light at the vector x, and radius 2.4 I would write:

    trap_R_AddLightToScene( x, 2.4, 1.0, 0.0, 1.0 );

    [This message has been edited by Nith Sahor : 10-04-2002.]

    Nith Sahor
    Recruit

    Posts: 9
    Registered: Sep 2002

    posted 09-28-2002 04:08 AM     Click Here to See the Profile for Nith Sahor     UIN: 118030089UIN: 118030089 
    qhandle_t trap_R_RegisterShader( const char *name );

    const char *name: pointer to the name of the shader (?)

    This function registers the name shader and gives it a unique qhandle_t.

    Waxy_Th_Chicken
    Gibblet

    Posts: 19
    Registered: May 2003

    posted 05-24-2003 05:36 PM     Click Here to See the Profile for Waxy_Th_Chicken    Click Here to Email Waxy_Th_Chicken 
    Trap_UpdateScreen

    cg_local.h says:
    // force a screen update, only used during gamestate load
    void trap_UpdateScreen( void );

    the Trap_UpdateScreen itself appears to be:
    cg_syscalls.c
    void trap_UpdateScreen( void ) {
    syscall( CG_UPDATESCREEN );
    }

    This is also called by:
    UI_Atoms.C

    void UI_UpdateScreen( void ) {
    trap_UpdateScreen();
    }


    it is also called by:
    ui_local.h
    void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
    void trap_UpdateScreen( void );
    int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );


    The locations of the calls and the remarks placed around it imply that this trap is ONLY for updating the screen during connection to local or remote host.

    (eg: Loading....shotgun ; Loading.... Gauntlet ect... during the load of a map.)

    ------------------
    -CLUCK!!!!!!!!


    ntba2
    Rookie

    Posts: 32
    Registered: Mar 2001

    posted 07-03-2003 01:58 AM     Click Here to See the Profile for ntba2     
    int trap_BotAllocateClient( void )

    Allocates a free client slot and returns the client number. Also marks the client as bot in the engine (arg2 will be 1 when a GAME_CLIENT_CONNECT message is dispatched to vmMain for this client).

    On failure, -1 is returned.


    This topic is 2 pages long:   1  2 

    All times are PST (US)

    Hop to:

    Contact Us | Quake3World.com


    Ultimate Bulletin Board 5.45c